<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    // 数组 copyWithin
    // 从start到end的位置选中，并且end到最后的位置复制一份
    let arr = [1, 2, 3, 4, 5, 6]
    let arr2 = arr.copyWithin(0, 3)
    console.log(arr2) // 4,5,6,4,5,6

    // 数组 find  找出第一个满足条件的
    let num = [1, 5, -3, 0, 3, -6, 4, 7, -10, 2]
    console.log(num.find(x => x > 0))

    // 数组 find  找出第一个满足条件的索引
    let num2 = [-1, 5, -3, 0, 3, -6, 4, 7, -10, 2]
    console.log(num2.findIndex(x => x > 0))


    console.log("==================================")

    // 数组entries
    // 返回一个遍历器
    for (let k of ['a', 'b'].keys()) {
        console.log(k)
    }

    for (let v of ['a', 'b'].values()) {
        console.log(v)
    }

    // 用entries来代替上面的两个循环
    for (let [k, v] of ['a', 'b', 'c', 'd'].entries()) {
        console.log(k, v)
    }

    ['a', 'b', 'c', 'd'].forEach((v, k) => {
        console.log(k, v)
    })

    const obj = {'name': 'jack', age: 21, email: '123@qq.com'}
    console.log('对象:',Object.entries((obj)))

    const arr3 = [{a: 2}, 3, 4]
    console.log('数组:',Object.entries((arr3)))

    // next
    let letter = ['a','b','c','d']
    let it = letter.entries()
    console.log(it.next().value)
    console.log(it.next().value)

    // inclues返回是否包含某元素
    console.log([1,2,3].includes(2))
    console.log([1,2,3].includes('2'))
</script>
</body>
</html>
